<?php

/**
 * The drawer class, the class which in the end creates the complete
 * image by using filters on it.
 *
 * @version $Revision v1.00$
 * @author Bryan Spirit & Mark Kazemier
 */
class Drawer
{
    private $m_oImage;
    private $m_oFilter;
    
    /**
     * Constructs a drawer with an Image (Canvas) and a filter to paint with
     *
     * @param Image The image that has to be painted
     * @param Filter The filter which is used to paint on the Image
     */
    public function __construct(Image $oImage, Filter $oFilter = null)
    {
        $this->m_oImage = $oImage;
        $this->setFilter($oFilter);
    }
    
    /**
     * Method to set the filter that has to be used by the Drawer
     *
     * @param Filter The filter to use
     */
    public function setFilter(Filter $oFilter)
    {
        $this->m_oFilter = $oFilter;
    }
    
    /**
     * Method to draw the image.
     *
     * @return string The output of the image
     */
    public function draw()
    {
        if($this->m_oFilter != null)
            $this->m_oFilter->filter($this->m_oImage);
        
        return $this->m_oImage->create();
    }
}
